#! /usr/bin/env python
# -*- coding: utf-8 -*-

# *************************************************************
#  Copyright (c) Huoty - All rights reserved
# 
#      Author: Huoty <sudohuoty@gmail.com>
#  CreateTime: 2016-11-07 15:56:25
# *************************************************************

from traitlets import HasTraits, Int, Unicode

class Foo(HasTraits):
    bar = Int()
    baz = Unicode()

foo = Foo()

def func(change):
    print(change['old'])
    print(change['new'])   # as of traitlets 4.3, one should be able to
                           # write print(change.new) instead

foo.observe(func, names=['bar'])
foo.bar = 2  # prints '0\n 1'
foo.bar = 3
foo.baz = 'abc'  # prints nothing

